# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=avahi-ui
pkgver=0.7
pkgrel=2
pkgdesc="Gtk user interface library for Avahi"
url="http://www.avahi.org/"
arch="all"
license="LGPL-2.0-or-later"
depends_dev="gdbm-dev"
makedepends="$depends_dev py3-gobject3-dev py3-dbus-dev intltool
	gobject-introspection-dev expat-dev libdaemon-dev glib-dev dbus-dev
	libcap-dev python3-dev autoconf automake libtool avahi-dev gtk+3.0-dev"
subpackages="$pkgname-dev $pkgname-tools $pkgname-gtk3"
source="http://www.avahi.org/download/avahi-$pkgver.tar.gz
	system-avahi.patch
	gnome-nettool.png"

_subdirs="avahi-ui avahi-python"
builddir="$srcdir"/avahi-$pkgver
prepare() {
	default_prepare
	autoreconf -vif
}

build() {
	# we dont build autoipd since dhcpcd does same job
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--disable-autoipd \
		--disable-qt3 \
		--disable-qt4 \
		--disable-gtk \
		--enable-gtk3 \
		--disable-mono \
		--disable-monodoc \
		--disable-doxygen-doc \
		--disable-xmltoman \
		--disable-compat-libdns_sd \
		--disable-compat-howl \
		--with-distro="gentoo" \
		--with-systemdsystemunitdir=/lib/systemd/system \
		--disable-python \
		--disable-static \
		--enable-shared
	for i in $_subdirs; do
		(cd $i && make)
	done
}

package() {
	make install-pkgconfigDATA DESTDIR="$pkgdir" \
		pkgconfig_DATA="avahi-ui-gtk3.pc"
	mkdir -p "$pkgdir"/usr/bin
	for i in avahi-ui avahi-python; do
		make -C $i DESTDIR="$pkgdir" install
	done
}

tools() {
	depends=""
	pkgdesc="UI tools for mDNS browsing"
	mkdir -p "$subpkgdir"/usr/bin
	cd "$pkgdir"/usr/bin
	mv b* "$subpkgdir"/usr/bin/
	install -D -m 644 "$srcdir"/gnome-nettool.png \
		"$subpkgdir"/usr/share/pixmaps/gnome-nettool.png

	# This depends on py-gtk
	rm -f "$subpkgdir"/usr/bin/avahi-bookmarks
}

gtk3() {
	pkgdesc="Gtk3 user interface library for Avahi"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libavahi-ui-gtk3.so.* \
		"$subpkgdir"/usr/lib/
}

sha512sums="bae5a1e9204aca90b90e7fd223d19e809e3514d03ba5fa2da1e55bf1d72d3d3b98567f357900c36393613dc17dc98e15ff3ebf0f226f2f6b9766e592452a6ce7  avahi-0.7.tar.gz
99723e66889601044ac5ca919e79aa328083cb377bb3d270f3e8d2baee27505f967949f72faa0424756e5f18b1359fd7f7fb30636861d47455ff7b92ed48bcfa  system-avahi.patch
d8e92fcdd82759f8de536ebfa356fe208c27b2d998ce5bb51d585dffc163dc16228be4a7108644fe1a11defbe750244bc8105a430b1397297cdef4cb83ab0db5  gnome-nettool.png"
